#encoding:utf8


def reload_module(module, recursion=True, visited_dict = {}, print_info = False):
  """reload module recursively or not"""
  reload(module)
  visited_dict[module] = 1
  if print_info: print("{0} has been loaded".format(module.__name__))
  if not recursion: return
  for m in module.__dict__.values():
    if type(m) == types.ModuleType and m not in visited_dict:
      reload_module(m, recursion = recursion,
                    visited_dict = visited_dict,
                    print_info=print_info)

